package com.jbm.jbmsupplier.util;
import java.util.ArrayList;

import com.jbm.jbmsupplier.model.*;
import com.jbm.jbmsupplier.ui.MainFrameActivity;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

import android.R.integer;

public class XmlRead extends DefaultHandler{
	private String content;
	JobInfo currentInfo = null;
	fileInfo currentFile = null;
	private static String userName=null;
	private static String userPwd=null;
	public XmlRead() {
		 currentInfo = MainFrameActivity.currentJob;
	}
	@Override
	public void startDocument()throws SAXException{
		super.startDocument();
	}
	
	@Override
    public void characters(char[] ch, int start, int length)
            throws SAXException {
		super.characters(ch, start, length);
		content = new String(ch, start, length);
	}
	
	 @Override
     public void startElement(String uri, String localName, String qName,
             Attributes attributes) throws SAXException {
		 super.startElement(uri, localName, qName, attributes);
		 if("fileInfo".equals(localName))
		 {
			 currentFile = new fileInfo(currentInfo,Integer.parseInt(attributes.getValue("file_type")));
			 currentFile.setFileName(attributes.getValue("file_name"));
			 currentFile.setPathName(attributes.getValue("path_name"));
			 currentFile.setDate(attributes.getValue("create_time"));
			 currentFile.setText(attributes.getValue("text"));
			 currentFile.setDec(attributes.getValue("file_dec"));
		 }
		 if("UserInfo".equals(localName)||"UserInfo".equals(qName))
		 {
			 XmlRead.userName = attributes.getValue("name");
			 XmlRead.userPwd = attributes.getValue("password");
		 }
	 }
	
    @Override
    public void endElement(String uri, String localName, String name)
            throws SAXException {
		 if("fileInfo".equals(localName))
		 {
		 }

    }
	public static String getUserName() {
		return userName;
	}
	public static void setUserName(String userName) {
		XmlRead.userName = userName;
	}
	public static String getUserPwd() {
		return userPwd;
	}
	public static void setUserPwd(String userPwd) {
		XmlRead.userPwd = userPwd;
	}
}
